package com.example.springboot.mapper;

import org.apache.ibatis.annotations.*;
import com.example.springboot.entity.User;

import java.util.List;

@Mapper
public interface UserMapper {


    @Select("SELECT * from sys_user")
    List<User> getAll();

    @Insert("INSERT INTO sys_user(username,password,nickname,email,phone,address)" +
            "VALUES(#{username},#{password},#{nickname},#{email},#{phone},#{address})")
    int insert(User user);

    int update(User user);

    @Delete("DELETE FROM sys_user WHERE id = #{id}")
    Integer deleteByID(@Param("id") Integer id);

    //分页查询
    @Select("SELECT * FROM sys_user where username like #{username} LIMIT #{page},#{pagesize}")
    List<User> selectPage(Integer page, Integer pagesize, String username);

    @Select("SELECT COUNT(*) FROM sys_user where username like #{username}")
    Integer selectTotal(String username);
}